import java.util.*;
class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;
    TreeNode() {}
    TreeNode(int val) { this.val = val; }
    TreeNode(int val, TreeNode left, TreeNode right) {
        this.val = val;
        this.left = left;
        this.right = right;
    }
}
public class newcoder {
    public static int i=0;
    public static TreeNode creatTree(String str) {
        TreeNode root=null;
        if(str.charAt(i)!='#') {
            root=new TreeNode(str.charAt(i));
            i++;
            root.left=creatTree(str);
            root.right=creatTree(str);
        } else {
            i++;
        }
        return root;；
    }
    public static void inOrder(TreeNode root) {
        inOrder(root.left);
        System.out.println(root.val+' ');
        inOrder(root.right);
    }
    public static void main(String[] args) {
        //输入
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        TreeNode root = creatTree(str);
        inOrder(root);
    }


}
